﻿using System;
using System.Globalization;
using System.Windows.Data;
using DependencyAnalysis.DataModel;

namespace theeg.DependencyAnalysis.CommonAddin.Converters
{
    public class HiddenNodeToNameConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var submodule = value as SubmoduleDescriptor;
            if (submodule != null)
            {
                var name = string.IsNullOrEmpty(submodule.FullName) ? "." : submodule.FullName;
                if (submodule.Module != null)
                {
                    return "Submodule: " + name + " in " + submodule.Module.FullName;
                }
                return "Submodule: " + name;
            }
            var module = value as ModuleDescriptor;
            if (module != null)
            {
                return "Module: " + module.FullName;
            }
            var type = value as TypeDescriptor;
            if (type != null)
            {
                return "Type: " + type.FullName;
            }
            var member = value as MemberDescriptor;
            if (member != null)
            {
                return "Member: " + member.FullName;
            }
            return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
